/***************************************************************************************
* Copyright (c) 2014-2022 Zihao Yu, Nanjing University
*
* NEMU is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*          http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
*
* See the Mulan PSL v2 for more details.
***************************************************************************************/

#ifndef __SDB_H__
#define __SDB_H__

#include "common.h"
#include "sim.h"
#include <readline/readline.h>
#include <readline/history.h>

typedef struct watchpoint {
  int NO;
  struct watchpoint *next;

  /* TODO: Add more members if necessary */
  char expr[32];
  word_t val;
} WP;


void init_monitor(int argc, char *argv[]);

// void read_elf(const char *elf_file);
// void ftrace_call (paddr_t pc , paddr_t dnpc);
// void ftrace_ret (paddr_t pc);
char* rl_gets();
int cmd_c(char* args);
int cmd_q(char* args);
int cmd_si(char* args);
int cmd_info(char* args);
int cmd_x(char* args);
int cmd_p(char* args);
int cmd_w(char *args);
int cmd_d(char *args);
int cmd_help(char *args);
void sdb_set_batch_mode();

void sdb_mainloop();
void init_sdb();
word_t load_img();

word_t expr(char *e, bool *success);
void cmd_watch(char *args);
void cmd_delete(char *args);
void print_wp();
int test_change(void);

#endif
